<template>
  <div>
    <div align="center">
      <label size="large" label-width="280px">— — — — — — — — — — — </label><br/>
      <label size="large" label-width="280px">* * * 供水爆管影响范围模型 * * *</label><br/>
      <label size="large" label-width="280px">— — — — — — — — — — — </label>
    </div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="350px">
      <el-form-item label="编号" prop="number">
        <el-input v-model="formData.number" placeholder="请输入编号" show-word-limit clearable
                  :style="{width: '80%'}"></el-input>
      </el-form-item>
      <el-form-item label="是输水管还是配水管" prop="sglx">
        <el-select v-model="formData.sglx" placeholder="请选择输水管还是配水管" clearable :style="{width: '80%'}">
          <el-option v-for="(item, index) in sglxOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="监测点这个时间前10天的瞬时流量平均值（m^3/s）" prop="jcdqst">
        <el-input-number  step="0.01" v-model="formData.jcdqst" placeholder="请输入监测点这个时间前10天的瞬时流量平均值（m^3/s）" clearable
                  :style="{width: '80%'}"></el-input-number>
      </el-form-item>
      <el-form-item label="监测点这个时间当前流量值（m^3/s）" prop="jcddqz">
        <el-input-number step="0.01" v-model="formData.jcddqz" placeholder="请输入监测点这个时间当前流量值（m^3/s）" clearable
                  :style="{width: '80%'}"></el-input-number>
      </el-form-item>
      <el-form-item label="下游支管数量" prop="xlzgsl">
        <el-input-number  step="1" v-model="formData.xlzgsl" placeholder="请输入下游支管数量" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
    <el-dialog
      title="评估结果"
      :visible.sync="centerDialogVisible"
      width="30%"
      center>
      <span>编号:{{number}};评估结果:{{name}}</span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="centerDialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
  import {handleSGBZ19} from "../../../api/edu/risk";

  export default {
    components: {},
    props: [],
    data() {
      return {
        centerDialogVisible : false,

        formData: {
          number: '',
          sglx: undefined,
          jcdqst: undefined,
          jcddqz: undefined,
          xlzgsl: undefined,
        },
        rules: {
          number: [{
            required: true,
            message: '请输入编号',
            trigger: 'blur'
          }],
          sglx: [{
            required: true,
            message: '请选择输水管还是配水管',
            trigger: 'change'
          }],
          jcdqst: [{
            required: true,
            message: '请输入监测点这个时间前10天的瞬时流量平均值（m^3/s）',
            trigger: 'blur'
          }],
          jcddqz: [{
            required: true,
            message: '请输入监测点这个时间当前流量值（m^3/s）',
            trigger: 'blur'
          }],
          xlzgsl: [],
        },
        sglxOptions: [{
          "label": "输水管",
          "value": 1
        }, {
          "label": "配水管",
          "value": 2
        }],
      }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
      submitForm() {
        handleSGBZ19(this.formData).then(response => {
          console.log(response)
          this.name = response.data.name;
          this.number = response.data.number;
          this.centerDialogVisible = true
        }).catch((error) => {
          console.log(error);
        });
      },
      resetForm() {
        this.$refs['elForm'].resetFields()
      },
    }
  }

</script>
<style>
</style>
